package net.hn.hnms.biz.common.activiti.builder;


import net.hn.hnms.biz.common.activiti.params.TaskParam;
import net.hn.hnms.biz.common.activiti.result.ProcessTaskResult;
import net.hn.hnms.biz.common.activiti.service.ProcessApiService;

/**
 * Created on 2022/8/5.
 *
 * @author ly
 * @desc: 流程任务参数查询器
 */
public class TaskVariablesQuery {

    //流程id
    private String taskId;

    //运行中的流程实例id
    private String processInstanceId;

    /**
     * 业务编码
     */
    private String businessKey;
    private ProcessApiService processApiService;

    private TaskVariablesQuery() {
    }

    public TaskVariablesQuery(ProcessApiService processApiService) {
        this.processApiService = processApiService;
    }

    public TaskVariablesQuery taskId(String taskId) {
        this.taskId = taskId;
        return this;
    }

    public TaskVariablesQuery processInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
        return this;
    }

    public TaskVariablesQuery businessKey(String businessKey) {
        this.businessKey = businessKey;
        return this;
    }

    /**
     * 查询需要传入的流程任务参数
     * @return ProcessTaskResult 需要传入的流程任务参数
     */
    public ProcessTaskResult query() {
        TaskParam taskParam = new TaskParam();
        taskParam.setTaskId(this.taskId);
        taskParam.setBusinessKey(this.businessKey);
        taskParam.setProcessInstanceId(this.processInstanceId);
        return processApiService.getTaskVariables(taskParam);
    }
}
